package com.huaju.enity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
 * Admin entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "admin", catalog = "licai")
@JsonIgnoreProperties(value={"smsrecords"})
public class Admin implements java.io.Serializable {

	// Fields

	private Integer aid;
	private Subcompany subcompany;
	private RoleType roleType;
	private String loginname;
	private String loginpwd;
	private String name;
	private String uname;
	private String tel;
	private String ip;
	private Date lastTime;
	private Date createTime;
	private Set<Smsrecord> smsrecords = new HashSet<Smsrecord>(0);

	/** default constructor */
	public Admin() {
	}

	/** full constructor */
	public Admin(Subcompany subcompany, RoleType roleType, String loginname,
			String loginpwd, String name, String ip, Date lastTime,
			Date createTime, Set<Smsrecord> smsrecords) {
		this.subcompany = subcompany;
		this.roleType = roleType;
		this.loginname = loginname;
		this.loginpwd = loginpwd;
		this.name = name;
		this.ip = ip;
		this.lastTime = lastTime;
		this.createTime = createTime;
		this.smsrecords = smsrecords;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "aid", unique = true, nullable = false)
	public Integer getAid() {
		return this.aid;
	}

	public void setAid(Integer aid) {
		this.aid = aid;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "com_id")
	public Subcompany getSubcompany() {
		return this.subcompany;
	}

	public void setSubcompany(Subcompany subcompany) {
		this.subcompany = subcompany;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "role_type_id")
	public RoleType getRoleType() {
		return this.roleType;
	}

	public void setRoleType(RoleType roleType) {
		this.roleType = roleType;
	}

	@Column(name = "loginname", length = 500)
	public String getLoginname() {
		return this.loginname;
	}

	public void setLoginname(String loginname) {
		this.loginname = loginname;
	}

	@Column(name = "loginpwd")
	public String getLoginpwd() {
		return this.loginpwd;
	}

	public void setLoginpwd(String loginpwd) {
		this.loginpwd = loginpwd;
	}

	@Column(name = "name", length = 500)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "ip")
	public String getIp() {
		return this.ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	@Column(name = "lastTime", length = 19)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	public Date getLastTime() {
		return this.lastTime;
	}

	public void setLastTime(Date lastTime) {
		this.lastTime = lastTime;
	}

	@Column(name = "createTime", length = 19)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	public Date getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "admin")
	public Set<Smsrecord> getSmsrecords() {
		return this.smsrecords;
	}

	public void setSmsrecords(Set<Smsrecord> smsrecords) {
		this.smsrecords = smsrecords;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public String getUname() {
		return uname;
	}

	public void setUname(String uname) {
		this.uname = uname;
	}

}